package cn.edu.just.firstjavaapp.l7;

public class Main {
    public static void main(String[] args) {
        // 定义一个Person数组，包含10个Person对象
        Person[] persons = new Person[10];

        // 初始化数组中的每个Person对象
        persons[0] = new Person("Alice", 25, "Female", 5000.00);
        persons[1] = new Person("Bob", 30, "Male", 6000.00);
        persons[2] = new Person("Charlie", 28, "Male", 5500.00);
        persons[3] = new Person("David", 22, "Male", 4800.00);
        persons[4] = new Person("Eve", 27, "Female", 5200.00);
        persons[5] = new Person("Frank", 35, "Male", 7000.00);
        persons[6] = new Person("Grace", 29, "Female", 6500.00);
        persons[7] = new Person("Hank", 24, "Male", 4900.00);
        persons[8] = new Person("Ivy", 26, "Female", 5300.00);
        persons[9] = new Person("Jack", 31, "Male", 6200.00);
        //printOlderThan(persons,28);
        //printPerson(persons,new Age28_31Check());
        //printPerson(persons,new GenderSalaryCheck());
        printPerson(persons, new Check() {
            @Override
            public boolean test(Person p) {
                return (p.age>=30 && p.salary>6000);

            }
        });
        System.out.println("------------------");
        printPerson(persons,p -> p.age>=30&& p.salary>6000);
        System.out.println("--------------------");
        printPerson(persons,p -> p.gender.equals("Female"));


    }
    public static void printOlderThan(Person[] person,int age){
        for(Person p:person){
            if(p.age>=age){
                p.print();
                System.out.println();;
            }
        }
    }

    public static void printPerson(Person[] person,Check check){
        for(Person p:person){
            if(check.test(p)){
                p.print();
                System.out.println();
            }
        }
    }

}
